home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #2 / Ham Radio 2000 - Volume 2.iso / HAMV2 / TCP_IP / TNOS230S / ENETDUMP.C < prev    next >
Encoding:
C/C++ Source or Header  |  1997-07-30  |  1.1 KB  |  60 lines

  1. /* Ethernet header tracing routines
  2.  * Copyright 1991 Phil Karn, KA9Q
  3.  */
  4. #include "global.h"
  5. #ifdef ETHER
  6. #include "mbuf.h"
  7. #include "enet.h"
  8. #include "trace.h"
  9.  
  10. #if !defined(_lint)
  11. static char rcsid[] OPTIONAL = "$Id: enetdump.c,v 1.11 1997/07/31 00:44:20 root Exp root $";
  12. #endif
  13.  
  14. void
  15. ether_dump(fp,bpp,check)
  16. FILE *fp;
  17. struct mbuf **bpp;
  18. int check OPTIONAL;    /* Not used */
  19. {
  20.     struct ether ehdr;
  21.     char s[20],d[20];
  22.  
  23.     (void) ntohether(&ehdr,bpp);
  24.     (void) pether(s,(char *) ehdr.source);
  25.     (void) pether(d,(char *) ehdr.dest);
  26.     traceprintf(fp,"Ether: len %u %s->%s",ETHERLEN + len_p(*bpp),s,d);
  27.  
  28.     switch(ehdr.type){
  29.         case IP_TYPE:
  30.             traceprintf(fp," type IP\n");
  31.             ip_dump(fp,bpp,1);
  32.             break;
  33.         case REVARP_TYPE:
  34.             traceprintf(fp," type REVARP\n");
  35.             arp_dump(fp,bpp);
  36.             break;
  37.         case ARP_TYPE:
  38.             traceprintf(fp," type ARP\n");
  39.             arp_dump(fp,bpp);
  40.             break;
  41.         default:
  42.             traceprintf(fp," type 0x%x\n",ehdr.type);
  43.             break;
  44.     }
  45. }
  46. int
  47. ether_forus(iface,bp)
  48. struct iface *iface OPTIONAL;
  49. struct mbuf *bp;
  50. {
  51.     /* Just look at the multicast bit */
  52.  
  53.     if(bp->data[0] & 1)
  54.         return 0;
  55.     else
  56.         return 1;
  57. }
  58.  
  59. #endif
  60.